﻿#include <Solar/CelestialBody.h>
#include <Solar/Solar.h>
#include <QApplication>
#include <CommonLib/MainWindow/MainWindow.h>
#include <CommonLib/ListWidget/ListWidget.h>
#include <Solar/Solar.h>
#include <Solar/SimulationTimer.h>

CSolar::CSolar()
{
    const double dScale = 1.0;
    std::vector<SCelestialBodyEle> vecCelestialBodyEles;
    vecCelestialBodyEles.push_back(SCelestialBodyEle("Sun", "Sun", "", 695500000 * dScale, 25.05, 0, 0, "Sun.jpg"));
    vecCelestialBodyEles.push_back(SCelestialBodyEle("Earth", "Earth", "Sun", 6371000 * dScale, 0.997258, 149600000000, 365.24219, "Earth.jpg"));
    vecCelestialBodyEles.push_back(SCelestialBodyEle("Moon", "Moon", "Earth", 1738140 * dScale, 27.32, 384400000, 27.32, "Moon.jpg"));
    for (auto stCelestialBodyEle : vecCelestialBodyEles)
    {
        osg::ref_ptr<CCelestialBody> rpCelestialBody = new CCelestialBody(stCelestialBodyEle);
        m_mapID2Body[stCelestialBodyEle.m_strID] = rpCelestialBody.get();
        this->addChild(rpCelestialBody.get());
    }
}

CSolar::~CSolar()
{

}

int solar( int argc, char **argv )
{
    QApplication app(argc, argv);
    CFxSimulationTimer *pTimer = CFxSimulationTimer::instance();
    CMainWindow mainWindow;
    CListWidget listWidget(&mainWindow);
    osg::ref_ptr<CSolar> rpSolar = new CSolar;
    listWidget.addModel("Solar", rpSolar.get());
    mainWindow.setGeometry( 100, 100, 800, 600 );
    mainWindow.show();
    return app.exec();
}
